package com.aidex.quartz.task;

import com.aidex.biz.domain.*;
import com.aidex.biz.domain.bo.BusinessSetBo;
import com.aidex.biz.domain.enums.CustomerEnum;
import com.aidex.biz.rong360.Rong360Service;
import com.aidex.biz.service.*;
import com.aidex.biz.utils.RAESUtils;
import com.aidex.common.core.domain.entity.SysUser;
import com.aidex.common.core.redis.RedisCache;
import com.aidex.common.utils.SecurityUtils;
import com.aidex.common.utils.StringUtils;
import com.aidex.common.utils.http.HttpUtils;
import com.aidex.framework.websocket.WebSocketUsers;
import com.aidex.system.service.ISysUserService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.*;

/**
 * 定时任务调度测试
 *
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask {
    @Autowired
    private SearchInfoService searchInfoService;
    @Autowired
    private ReptileService reptileService;
    @Autowired
    private SearchInfoDetailsService searchInfoDetailsService;
    @Autowired
    private CustomerService customerService;
    @Autowired
    private ISysUserService iSysUserService;
    @Autowired
    private TempShareService tempShareService;

    @Autowired
    private JinjianCodeService jinjianCodeService;

    @Autowired
    private BusinessSetService businessSetService;

    @Autowired
    private RxkOrderService rxkOrderService;

    @Autowired
    private CustomerDongtaiService customerDongtaiService;

    public String ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
        return "sdfsdfsdf";
    }

    public void ryParams(String params) {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams() {
        System.out.println("执行无参方法");
    }


    public void reSetDaySort() {
        jinjianCodeService.deleteJinjianCodeByIds(new String[]{});
    }

    /**
     * 京东爬虫
     *
     * @throws IOException
     * @throws InterruptedException
     */
    public void taskReptileJd() throws IOException, InterruptedException {
        SearchInfo searchInfo = new SearchInfo();
        searchInfo.setStatus("0");
        searchInfo = searchInfoService.findOne(searchInfo);
        if (null == searchInfo) {
            return;
        }
        String keyword = searchInfo.getName() + searchInfo.getBrandName();
        List<String> stringList = reptileService.runReptileByJd(keyword);
//        for (String url : stringList) {
//            SearchInfoDetails searchInfoDetails = new SearchInfoDetails();
//            searchInfoDetails.setBrandName(searchInfo.getBrandName());
//            searchInfoDetails.setName(searchInfo.getName());
//            searchInfoDetails.setUnit(searchInfo.getUnit());
//            searchInfoDetails.setInfoId(searchInfo.getId());
//            searchInfoDetails.setUrl("https://" + url);
//            searchInfoDetailsService.save(searchInfoDetails);
//        }
        if (stringList.size() > 0) {
            searchInfo.setDetailsId("https://" + stringList.get(0));
        }
        searchInfo.setStatus("2");
        searchInfoService.save(searchInfo);
    }


    /**
     * 用户分配
     */
    public void taskCustomerShare() {

        Customer customer = customerService.findOne();
        if (customer != null) {
            Map<String, Object> params = new HashMap<>();
            if (!StringUtils.isEmpty(customer.getCityName())&& !StringUtils.isEmpty(customer.getLaiyuan())) {
                String[] area = customer.getCityName().split("-");
                if (area.length == 2) {
                    params.put("cityName", area[1].replace("市", ""));
                } else if (area.length == 1) {
                    params.put("cityName", customer.getCityName().replace("市", ""));
                }

                params.put("laiyuan", customer.getLaiyuan());
//                if (1 == customer.getIsRep()) {
//                    params.put("userId", customer.getUserId());
//                } else {
                    params.put("userId", null);
//                }
                List<SysUser> sysUserList = iSysUserService.findShareUser(params);
                if (null == sysUserList || sysUserList.size() == 0) {
                    //没有可分配的用户了  表示一轮已经分完了
                    SysUser sysUser = new SysUser();
                    sysUser.setCity(params.get("cityName").toString());
                    sysUser.setBusType(params.get("laiyuan").toString());
                    List<SysUser> shareUserList = iSysUserService.findList(sysUser);
                    if (shareUserList.size() > 0) {
                        tempShareService.deleteAll(shareUserList);
                    }
                    //重新查询
                    sysUserList = iSysUserService.findShareUser(params);
                }
                //如果查询到用户列表取第一个用户 如果没有用户了，返回空用户
                SysUser user = sysUserList.size() > 0 ? sysUserList.get(0) : null;
                if (null == user) {
                    // 分给客户经理 找客户经理
                    List<SysUser> mSysUserList = iSysUserService.findUserByCity(params);
                    user = mSysUserList.size() > 0 ? mSysUserList.get(0) : null;
                    if (null == user) {
                        customer.setStatus(CustomerEnum.FP_SHIBAI.getStatus());
                        customer.setInfo("分配用户为空，用户经理为空！");
                        customerService.save(customer);
                    } else {
                        customerService.shareCustomer(customer, user, true);
                    }
                } else {
                    customerService.shareCustomer(customer, user, true);
                }

            } else {
                customer.setStatus(CustomerEnum.FP_SHIBAI.getStatus());
                customer.setInfo("城市为空/来源为空/"+customer.getCusName());
                customerService.save(customer);
            }
        }
    }

    /**
     * 每天 凌晨 重置日分配数量
     */
    public void taskResetDayShareCount() {
        iSysUserService.resetDayShareCount();
    }

    /**
     * 定时获取 融360的数据 每2分钟一次
     *
     * @param
     */

    public void taskGetRong360Ningbo() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5001896";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALAOzaBqs9iNi42O" + "fOsHFEaFM14aOwR3wdB8ocYBPVsVHkmU6NPc+qwtqM37CHS6Y/qu8wnhRBDri55Q" + "h6dwOdEjjnmRPE3zrHVO8srsEEkwxCDKoohJyVuOG8obX+p9eekYqLaly4DNCAsR" + "8OcGjD9rhlGyvxu6ANyaXavZXGERAgMBAAECgYAXNdxmCassIX0EbISLd6N0qJrd" + "DRg6vo8OrV+mewNbvqz/hmIrjDZ//IUEotO6j9gedHIWG1yd3m/Jr1Qy/tigQbaO" + "5GnGZ+f9hTMsliarGFV/hp6+4Ozyr8g/2ruS5IawBC5g2S3trRkfPjxd/e9SWMBW" + "I9FBxz4A3CbKVfBPAQJBAOK9rbWoX3bNOSqwF+iLsZObArKRe27yFjIQw8kQWYte" + "Ipiq5NXQBf/yx6kt940iQIVcm2N2FTmUZmJLoTGGyncCQQDGxtKkzXK0Yt3iV/rL" + "9G/SPUUVRfvMRKzN+IvsC9gNy4W0L+wi+0bM4bKZP0EvEGMp4EN18K6LztRCRf9f" + "7wq3AkBuLObMn20LyDrgAEMNz1tRMwBDjqegyGd6mmTYPWaVbv92mYuqTXOs4+aa" + "0Wg5nwwlAVPMJ6O2n+KEHuXLsAiPAkEArKctd2/r3bqyN1Nrx5N9PQNy6dNrrjVI" + "U287Ob/f3buVWrj1Rj0zdenkEy/aEmMNfuYIMnznXxA7VYUvF8itaQJAXqraVOi9" + "AwJXEviYjrCOD3Bf9Bc2rVKiMdhO/dXydZ/dOtL1qbTUmCJP+z/gC+/kssNkxI2p" + "aUsjyNuQdyQLRg==";
        //融360分配的总账号ID, 联调时替换
        String uid = "859253";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }




    }

    /**
     * 定时获取 融360的数据 每2分钟一次 上饶
     *
     * @param
     */

    public void taskGetRong360WenZhou() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5001897";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMKlRQHFLM7zHjcZ" + "Om/Q0ym92a9+jH7+YyVdMk31+UjxP5ksl+lDsDAKffx0FSUz4w4cnUNKvOW8k1kx" + "0su5ofS7IpSHb7QbtoOrZ0YCCnOMVbIW/RNc1G5qxhu/lx+3cIiM05OBhPGdT3NH" + "KFngPr7u+hdto2BK6AdOFA2EReGhAgMBAAECgYAdrGJbxbpyBkA5+B+fgj9e4rF3" + "/pvelFt7C70qg3AwfY7LhC/YgNgwSrkwLmY22LUpppUW+CLaByiTdXQEWNVmnK1G" + "8ofN3GfhtxQM4Lm1WeBkzMsICzsGUW+TJLkIjNg2NM7hc/Npd0HbsAKbxIZ+ItSm" + "WXCIUGwBELlQ84wujQJBAOjsaPH+Z/+e0X0FWsPrVrbwFkOYs4Hd/JCuDQDlKUi0" + "HxS6M7yFq+7t9epMar3Csn6hlLJdKrc8VfFrLh1EN2MCQQDV7gZ8ixb2Th3GAAo6" + "CE5fo83c4H8o9R+33UNxpGAa7dZq+lZ/j+dYdVlXD4tulBDqIzxXu1AfnZz/o189" + "Q1wrAkASIu5dAXE5nzUypesWXEnJPtKM+uPnVdCnt1W93xoi1huhcoo6wLHNjevb" + "DY42LmXVpGE+rjB4ShNrE+xoTPp/AkEAlz/daCpyhpu+IyIeGN+MgcPvJW23mb6M" + "uVL/fxZHOGLVSPdLNo8IcpstGgeMfhbDSra00BZH1MJ7oKXiDQ9V1wJARP5Gpy6Y" + "djmVfmo6/cVuV9CM8GCQ6BPNn8IEGjLr5DqZYNzOoyn/h8t70tKEAEW8caSNB0QK" + "CtUH2juD5RpsoA==";
        //融360分配的总账号ID, 联调时替换
        String uid = "859254";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
//        System.out.println(service.getorderlist(params));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }
    /**
     * 定时获取 融360的数据 每2分钟一次 吉安
     *
     * @param
     */
    public void taskGetRong360JiAn() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId="5002270";
        uid="863220";
        privateKey="MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANsUvRrVJLjOa/Px"
                + "RtApl8EPXp9ZojhDkrbDiwYiRoSddGvAW6PUVG6+piBGSP/2+q4fjeJ6nbt/y1vp"
                + "HOM3yIMrieaZprlKEyP1mCixu0mw2necXb2/4TFBtzioQR7X9a0/jAVy2ovi7l4F"
                + "Q6HuPIeMVLwVbkA1dDikFrMD1mGtAgMBAAECgYEAzb8QSd7aeeUCZTq28k/dgSZa"
                + "CvU27/gmFRZXvg76gxkMeRVR+u4xzT+m7LCVZi4hBt4DdisJb0l5RnwK8Sk2WJzb"
                + "LIAdOMtPo1NoeiCVu/0k9hrXic4UrunPEA4C9d6jSy0lxxHT2gduPRiJVZ7oAcL2"
                + "Nb1KU441umQZUlm9cIECQQDyoNfUvGxblKtAPH9oMNVmMNcofJmQZLDueGDWpe/1"
                + "+VmlcD42OyjlrjXg9OrXqtUw2cUL2eJENemOR52bSkGVAkEA5yes4KjHUHQP6czO"
                + "VZqByg0nqnGAZmVnhmn540M4ubffZ4bbFj6bfjCD88QZkGXwANb70H8NCEfn/fw+"
                + "eTPJuQJAVfuMITbZC6dm/O+zkv/jUEC0rwNhBFu6m/gLEWZi4H+KNmfNlDho6ORQ"
                + "8bS52M4QmSxDeUyws82LREG658Jr9QJBAOZwYSHeYETOT4buy8v/KeB52M9MM4rh"
                + "EKGpSJrNSuGqcqbMg+DbLTxRtVnwZuPTG75ak9M4tY9Jz/cd3lIJ1NECQCwnJBYr"
                + "iZ8cAoQ/Ko2fGbuJT0VAKuVgHjfw9ineguRrhjEj8dS6uWnKspM6rFAllhQaQQ5t"
                + "JoekbJ16KwAqYBQ=";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 宜春
     *
     * @param
     */
    public void taskGetRong360YiChun() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId="5002271";
        uid="863207";
        privateKey="MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALDsf6yfcBjM3QDg" + "4CvbpwBg9TA0DalcBsbM0eImZ8s2gSSl2s4tU3hWNB5TJKmnRe8rX/dgW/kQeJBt" + "xd9P6t1DgQE0ANJcokwewFeXuVpgtEp8fOAoxEgJyoNlQSDSqfFdVxTZDSR6fuN/" + "vnR/MOslz09ZKcaLPDYAR5O57npHAgMBAAECgYEAlGGEoo4FQYdvQrFW0PGjGho3" + "CHpfis53kHtu+zAilLfdj5LZ81joTGBfzZ8FfJOhf3jtP1c9S6GYu+iUrzkjS5G3" + "UjYIE3Fy5rafN0vEKXf9bK16vtpMu+e0VuvrHlb6YW5CD6IHQ+2OONIpLIvbEuPl" + "fQAMj4aMKBfKsdlvg0ECQQDW0+mcY+SkFCq+/DdTr+riy6j4IXwwzuEJpiTr93cH" + "NA8XlPoLn9dX5AK52nfKbx/x4UyE5spc3ux30JEXxJw/AkEA0tTn1hawmy7MSDVV" + "epbQ0PMPkl6mNp1OwqkisA0yed/tEzwpgFu0guU4hTJVeZt6F0sHQYpJF2nLZ9lH" + "IwE/+QJAA6sEnx35hm+ttysZSr2DNjIiBXKU60RtBTwn/ztvddkGtPFfP5mQFLkY" + "7tFzICq7kea15sMGC4Xm5bjS8WPzAwJBAIkBSdbZz9JISv/xiKatMu1Vxhy73Q9I" + "klH1T1FQgiio14rUYbPD5D3bbys/VkQ8QM66NvDkSDMq0L+fdpbMzSECQQCyYzLw" + "BHyAMK6j4r+SGQ7JQnrnadfkWAszGfkfK/XT/iaLvOuMqXJ4Ja8U0dqnvVQmq5Xq" + "LWh+txpW14poEPR2";

        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 抚州
     *
     * @param
     */
    public void taskGetRong360FuZhou() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId="5002272";
        uid="863203";
        privateKey="MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOhPrQdKPfeJTIr1" + "pY049H7AUIkw5RtJAFDlIx+5hPAueULHWfTv6zVwlMt9YQF0kZA4Z9FESWm0qzL7" + "0LlpRqpdPqSClhA9L4yExtm47Pbmcmer50b4g41qI8tfFjWYeFdgsngtbI4wqdv3" + "SsbxPgQ9sl9aCl6jrSNG2fDCOJcpAgMBAAECgYAEcCE6Fm0AoZrYvMCg5gmlsj7X" + "oBuAXfCnmvkEziKABCNE51IMn9i6eKAfExIbWQK+4pT5JnjQkCcFHlJqeFxlM3it" + "dx4UcrmkxZaIWaGxjSYYe1qi3LX3ysbWPjoxBJSSXSjQK4zx6CIiPHlp2Z8oq1Qa" + "eHN2I/DdlBaqa7y20QJBAPpPZWFBZjmFWmJZ7tX/ri28ZvP8VKgDuqppUb1jxGtl" + "OU3b3hjTkt2HkLSR3n1iGGnjCqZDe4Bkuw23AWqeJR8CQQDtl4prCLBkkPGtm/V8" + "RciMnfNV8319UEhff2DglfhhGD2eDE+T9exh2QRjgnOw/p9BP9T/ch1Uj0DE8iqO" + "lDK3AkB7mzd6BlyfrQ2MIdMCVEdECJRiicmYSnckbevSdXDqg8r/esK7Scdto+M+" + "eAYBrq5Vo6t/nTVgmt2QET4e00eLAkEA2a6HTouWeX1nQGXs4+BX36XzxaMiLYc5" + "1+0vyHT/LY51HfIvkuO1oOyhnb5u2xJevPyL3UMjZk8dy5QIs7tKPwJBAL5LNKud" + "bxVPOO+jJ1Q1hsDZQGS5G63Isjxo0Pvc1XQLs4Pxg3P/1vBywNwDZJhXcz0LgIga" + "TZj9kItOvx1mx60=";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 定时获取 融360的数据 每2分钟一次 九江
     *
     * @param
     */
    public void taskGetRong360JiuJiang() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId, uid, privateKey;
        appId="5002273";
        uid="863202";
        privateKey="MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOsRASgqYOhzKtZA" + "/5fd1PmIFzm" +
                "/G3hmMqIvy3jVg7awrqWlLkLqynEnt3qkhGiPlIrtCyUW84fqyx9G" + "9PUTapMWVFojCKNYxSlZjLV5agqHUz5EEDpjsfU4o/GKUguJPZAQ/sbwlMi7gm8K" + "hxyvDLehnAh156ouDtgvoqPK3fzvAgMBAAECgYEA3XVMwLmESRrPXcEoy7vrfRdw" + "wi/AwqKNy2z55iJKD+DO+THwroyjIw4G9x1tvVCf4m7GlC/WSdOzgAkKmKWtPY2H" + "q2hAB2pnIX+jQpS4cLqxmIG/eaus+mNRhhUTa+086xSmiJHac+eLzQ0n/l7wxZtQ" + "CwDQ3b12gBRAZTwDmJkCQQD4I8/9bMt5KvSHA8knGg4yjK3hdl+TuHFH9LjNgkp8" + "hu6YLQVGMWyZLL5umIZGypacfRn4nGlK4PwNW4KrfoYVAkEA8oMtnbbxv4qiMCyP" + "oPU03DK2kPbOnRTPR6baV5zYyLY/e2RBAs1QOecusADur0c/TsrUEO/tMdLZH/EK" + "F76b8wJABdxysT28oKQPGpFQUwgehbsk8Epnf4m/wz9YjiIhuEdHo3iMw1evhP61" + "kM8xfMKURCYAUwr+wbIGwhoDQCHA8QJBALxRBvwgkutFMRqtj77SioCvVLuPG/Q4" + "s5kVRRmhr2l0tCkSObV+T10XW1bK8o3jipKZyEF6vjrhWz+Fgmvb1OcCQHVjY8xz" + "3M+UdWMq5mCpVZqc7Uk0gwWuodv7i4YeA5A9JB5ERlBNueUv1uSzFWA5JCvK1zwE" + "8WCnGTPQbilju3Y=";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }


    /**
     * 定时获取 融360的数据 每2分钟一次 赣州
     *
     * @param
     */

    public void taskGetRong360GanZhou() {
        boolean isTest = false;
        // 融360分配的appid, 上线时替换
        String appId = "5002343";
        // 融360分配的密钥, 注意不能删除回车和空格, 上线时替换
        String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANYsKTKFGDkm4xgm" +
                "JKDoEIpvI5qgvHR0dv/Mx2ope2nItjMnXU3VEdN3lVW8VmCeIKRigJQUfkYEqNOH" +
                "ucHNVM3X6nh+BBLnGEj3Q963SWpf9wLuY+ErrnRpo0kSIs7jvJf/4/Ln21dEBG3W" +
                "K8O+VSMffziyH7L2SHV0gMk0e1JRAgMBAAECgYAHMIRRhdZCVOPas60XGbM0cnan" +
                "gi3RWveDrsQi9DGIY4x6OyAOtNBcYO9KaYAczjIaUpQuZGG4x/9C2pOJxfLKxmmz" +
                "zpb4gtnMmlypsY/7riD0N6oAQbYz3mw8GzzHFGxQf1UaQmy3itZgqOGyOR7km/sC" +
                "5LFwzEQAavrdPb5GAQJBAPu2Zuox3UzOb1CynpQTay49aZCmbySP8lermVzGD8tw" +
                "SqjUChd1rYXaqv5rd3PUHvTradPeknJcVa5vFiTbJakCQQDZ0hCczpci3P9VblXB" +
                "RTZWbA+FC6aoWIGILlDRL8sOmBBoGQiFHNLBMqnLYA2Xo7lb9a9AbSv0AP1y1hh1" +
                "neBpAkAPxDAUEUWETxXn3xhRvBmljtEy70nc52tNlIEJr5pDqufyRT3QlF1nGfhF" +
                "8WNNDQdXXfuF+tX/dcskHu8rJdLpAkB0eEmfvyu7XZY+NSAvlvWmImPuDTvQ+npQ" +
                "ugtGv5qBNDhZoUEYBECBQ7jc4YCDG+2KSYWrGnUNJNZg6C/t/Dw5AkEA5aO92mDU" +
                "FApf1sUzmvYvB8pxkFksIuxsiyF7QZJAzF4E4jU+vPy8rV8VkL1kAUr5RE5MCrSp" +
                "FHwsUqFN1+YAwg==";
        //融360分配的总账号ID, 联调时替换
        String uid = "863208";
        Rong360Service service = new Rong360Service(appId, privateKey, isTest);
        // 获取订单接口
        Map<String, String> params = new HashMap<String, String>();
        params.put("uid", uid);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        params.put("end_time", simpleDateFormat.format(calendar.getTime()));
        // 将当前时间减去两分钟
        calendar.add(Calendar.MINUTE, -2);
        params.put("begin_time", simpleDateFormat.format(calendar.getTime()));
//        System.out.println(service.getorderlist(params));
        JSONObject jsonObjectRsp = JSONObject.parseObject(service.getorderlist(params));
        if ("200".equals(jsonObjectRsp.getString("error"))) {
            JSONObject orderListRsp = jsonObjectRsp.getJSONObject("bd_api_common_order_getorderlist_response");
            JSONArray cusList = orderListRsp.getJSONArray("data");
            for (int i = 0; i < cusList.size(); i++) {
                System.out.println(cusList.getJSONObject(i).getString("city"));
                Customer customer = new Customer();
                customer.setClueId(cusList.getJSONObject(i).getString("id"));
                customer.setCityName(cusList.getJSONObject(i).getString("city"));
                customer.setCusName(cusList.getJSONObject(i).getString("user_name"));
                customer.setPhone(cusList.getJSONObject(i).getString("user_mobile"));
                customer.setAmount(cusList.getJSONObject(i).getString("application_limit"));
                customer.setRemark(cusList.getJSONObject(i).getString("product") + "/" + cusList.getJSONObject(i).getString("qsearch"));
                customer.setLaiyuan("融360");
                customerService.savePushCustomer(customer);
            }
        }
    }

    /**
     * 融享客
     */
    public void taskGetRxkOrderCustomers() {
        RxkOrder rxkOrderparam = new RxkOrder();
        rxkOrderparam.setStatus("0");
        RxkOrder rxkOrder = rxkOrderService.findListByStatus(rxkOrderparam);
        if (null != rxkOrder) {
            String get_url = "https://gw.youxinsign.com/rxk-saas/api/organ-clue-api/readClues";
            String voucherCode = "3AIIJYJMI3UHVS5D";
            String key = "5BPZ3OLV41U8HB5L";
            String orderNo = rxkOrder.getOrderNo();
            JSONObject params = new JSONObject();
            params.put("voucherCode", voucherCode);
            params.put("orderNo", orderNo);
            JSONObject jsonObject = JSONObject.parseObject(HttpUtils.doPost(get_url, params));
            if ("1".equals(jsonObject.getString("code"))) {
                if(StringUtils.isEmpty(jsonObject.getString("data"))){
                    return;
                }
                JSONArray customerJsonList = JSONObject.parseArray(RAESUtils.decrypt(jsonObject.getString("data"),
                        key));
                for (int i = 0; i < customerJsonList.size(); i++) {
                    JSONObject customerJson = customerJsonList.getJSONObject(i);
                    if (null != customerJson) {
                        rxkOrder.setStatus("1"); // 读取成功
                        Customer customer = new Customer();
                        customer.setLaiyuan("融享客");
                        customer.setClueId(customerJson.getString("orderNo"));
                        customer.setCusCanal(customerJson.getString("source"));
                        customer.setCusBody(customerJson.getString("cstSource"));
                        customer.setCusName(customerJson.getString("name"));
                        customer.setAge(customerJson.getInteger("age"));
                        customer.setRemark(customerJson.getString("productName"));
                        customer.setPhone(customerJson.getString("phone"));
                        customer.setSex(customerJson.getInteger("sex") == 0 ? "女" : "男");
                        customer.setCityName(customerJson.getString("city"));
                        Optional.ofNullable(customerJson.getInteger("profession")).ifPresent(v -> {
                            switch (customerJson.getInteger("profession")) {
                                case 200:
                                    customer.setWorks("上班族");
                                    break;
                                case 300:
                                    customer.setWorks("自由职业");
                                    break;
                                case 400:
                                    customer.setWorks("企业主");
                                    break;
                                case 500:
                                    customer.setWorks("个体户");
                                    break;
                                case 800:
                                    customer.setWorks("公务员");
                                    break;
                                case 900:
                                    customer.setWorks("其他");
                                    break;
                            }

                        });

                        Optional.ofNullable(customerJson.getInteger("incomeMonth")).ifPresent(v -> {
                            customer.setIncomeMonth(customerJson.getInteger("incomeMonth")+"");
                        });



                        Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                            switch (customerJson.getInteger("sesameScore")) {
                                case 0:
                                    customer.setSesameScore("无芝麻分");
                                    break;
                                case 10:
                                    customer.setSesameScore("600分以下");
                                    break;
                                case 20:
                                    customer.setSesameScore("600~650分");
                                    break;
                                case 30:
                                    customer.setSesameScore("650~700分");
                                    break;
                                case 40:
                                    customer.setSesameScore("700分以上");
                                    break;
                            }

                        });
                        Optional.ofNullable(customerJson.getString("loanMoney")).ifPresent(v -> {
                            customer.setAmount(customerJson.getString("loanMoney").substring(0, customerJson.getString(
                                    "loanMoney").indexOf(".")) + "万元");
                        });

                        Optional.ofNullable(customerJson.getInteger("loanExpiresMonth")).ifPresent(v -> {
                            customer.setLoanExpiresMonth(customerJson.getInteger("loanExpiresMonth"));
                        });

                        Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                            // 有值的处理逻辑
                            switch (customerJson.getInteger("loanUse")) {

                                case 10:
                                    customer.setLoanUse("消费贷");
                                    break;
                                case 20:
                                    customer.setLoanUse("结婚贷");
                                    break;
                                case 30:
                                    customer.setLoanUse("购房贷");
                                    break;
                                case 40:
                                    customer.setLoanUse("装修贷");
                                    break;
                                case 50:
                                    customer.setLoanUse("购车贷");
                                    break;
                                case 60:
                                    customer.setLoanUse("教育贷");
                                    break;
                                case 70:
                                    customer.setLoanUse("旅游贷");
                                    break;
                                case 80:
                                    customer.setLoanUse("医疗贷");
                                    break;
                                case 90:
                                    customer.setLoanUse("其他贷");
                                    break;
                            }
                        });

                        Optional.ofNullable(customerJson.getInteger("gjjScop")).ifPresent(v -> {

                            switch (customerJson.getInteger("gjjScop")) {
                                case 0:
                                    customer.setAccumulation("无公积金");
                                    break;
                                case 10:
                                    customer.setAccumulation("缴纳未满6个月");
                                    break;
                                case 20:
                                    customer.setAccumulation("缴纳6个月以上");
                                    break;
                            }
                        });


                        Optional.ofNullable(customerJson.getInteger("sbScop")).ifPresent(v -> {

                            switch (customerJson.getInteger("sbScop")) {
                                case 0:
                                    customer.setSocial("无社保");
                                    break;
                                case 10:
                                    customer.setSocial("缴纳未满6个月");
                                    break;
                                case 20:
                                    customer.setSocial("缴纳6个月以上");
                                    break;
                            }
                        });

                        Optional.ofNullable(customerJson.getInteger("house")).ifPresent(v -> {
                            switch (customerJson.getInteger("house")) {
                                case 0:
                                    customer.setHouseType("无房产");
                                    break;
                                case 10:
                                    customer.setHouseType("有房产，不抵押");
                                    break;
                                case 20:
                                    customer.setHouseType("有房产，可抵押");
                                    break;
                            }

                        });

                        Optional.ofNullable(customerJson.getInteger("car")).ifPresent(v -> {
                            switch (customerJson.getInteger("car")) {
                                case 0:
                                    customer.setCarStatus("无车产");
                                    break;
                                case 10:
                                    customer.setCarStatus("有车产，不抵押");
                                    break;
                                case 20:
                                    customer.setCarStatus("有车产，可抵押");
                                    break;
                            }

                        });

                        Optional.ofNullable(customerJson.getInteger("baodanScop")).ifPresent(v -> {

                            switch (customerJson.getInteger("baodanScop")) {
                                case 0:
                                    customer.setBaodanScop("无保险保单");
                                    break;
                                case 10:
                                    customer.setBaodanScop("缴纳未满1年");
                                    break;
                                case 20:
                                    customer.setBaodanScop("缴纳1年以上");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("credit")).ifPresent(v -> {

                            switch (customerJson.getInteger("credit")) {
                                case 0:
                                    customer.setZx("无信用记录");
                                    break;
                                case 10:
                                    customer.setZx("信用良好无逾期");
                                    break;
                                case 20:
                                    customer.setZx("2年内逾期少于9次无90天以上逾期");
                                    break;
                                case 30:
                                    customer.setZx("2年内逾期少于9次有90天以上逾期");
                                    break;
                                case 40:
                                    customer.setZx("2年内逾期大于9次");
                                    break;
                                case 50:
                                    customer.setZx("半年内有60天以上逾期");
                                    break;
                                case 60:
                                    customer.setZx("半年内无60天以上逾期");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("isLoans")).ifPresent(v -> {
                            switch (customerJson.getInteger("isLoans")) {
                                case 0:
                                    customer.setIsLoans("无微粒贷");
                                    break;
                                case 10:
                                    customer.setIsLoans("1~2千");
                                    break;
                                case 20:
                                    customer.setIsLoans("2~5千");
                                    break;
                                case 30:
                                    customer.setIsLoans("5千~1万");
                                    break;
                                case 40:
                                    customer.setIsLoans("1万以上");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("manageYears")).ifPresent(v -> {
                            switch (customerJson.getInteger("manageYears")) {

                                case 10:
                                    customer.setManageYears("1年以下");
                                    break;
                                case 20:
                                    customer.setManageYears("1年至5年");
                                    break;
                                case 30:
                                    customer.setManageYears("5年以上");
                                    break;

                            }
                        });
                        Optional.ofNullable(customerJson.getString("turnover")).ifPresent(v -> {
                            customer.setTurnover(customerJson.getString("turnover"));
                        });
                        Optional.ofNullable(customerJson.getString("turnoverPublic")).ifPresent(v -> {
                            customer.setTurnoverPublic(customerJson.getString("turnoverPublic"));
                        });
                        Optional.ofNullable(customerJson.getInteger("workingYears")).ifPresent(v -> {
                            switch (customerJson.getInteger("workingYears")) {
                                case 10:
                                    customer.setWorkingYears("0~6个月");
                                    break;
                                case 20:
                                    customer.setWorkingYears("6~12个月");
                                    break;
                                case 30:
                                    customer.setWorkingYears("12个月以上");
                                    break;
                            }
                        });
                        Optional.ofNullable(customerJson.getInteger("registAddress")).ifPresent(v -> {
                            customer.setRegistAddress(customerJson.getInteger("registAddress") == 10 ? "本地" : "外地");
                        });
                        Optional.ofNullable(customerJson.getInteger("hasBusinessLicense")).ifPresent(v -> {
                            switch (customerJson.getInteger("hasBusinessLicense")) {
                                case 0:
                                    customer.setHasBusinessLicense("未注册");
                                    break;
                                case 10:
                                    customer.setHasBusinessLicense("注册1年以下");
                                    break;
                                case 20:
                                    customer.setHasBusinessLicense("注册1至5年");
                                    break;
                                case 30:
                                    customer.setHasBusinessLicense("注册5年以上");
                                    break;
                            }
                        });

                        Optional.ofNullable(customerJson.getInteger("creditCard")).ifPresent(v -> {
                            customer.setCreditCard(customerJson.getInteger("creditCard") == 0 ? "无信用卡" : "有信用卡");
                        });
                        Optional.ofNullable(customerJson.getString("apiSourceName")).ifPresent(v -> {
                            customer.setApiSourceName(customerJson.getString("apiSourceName"));
                        });
                        Optional.ofNullable(customerJson.getString("followUserName")).ifPresent(v -> {
                            customer.setFollowUserName(customerJson.getString("followUserName"));
                        });
                        Optional.ofNullable(customerJson.getString("brand")).ifPresent(v -> {
                            customer.setBrand(customerJson.getString("brand"));
                        });

                        Map map = customerService.savePushCustomer(customer);
                        if (map.get("code").equals("200")) {
                            String return_url = "https://gw.youxinsign" +
                                    ".com/rxk-saas/api/organ-clue-api/updateClueStatus";
                            params = new JSONObject();
                            params.put("voucherCode", voucherCode);
                            params.put("orderNo", orderNo);
                            params.put("status", 1);
                            params.put("remark", map.get("message"));
                            JSONObject.parseObject(HttpUtils.doPost(return_url, params));
                        }
                    }
                }
            }
        }
    }

    /**
     * 业务设置 定时任务-处理自动成为成交客户 每天凌晨1点
     *
     * @param
     */
    public void taskBusinessSettingByCjCustomer() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            JinjianInfo jinjianInfo = new JinjianInfo();
            switch (businessSet.getJinjianStatusValue()) {
                case "yfk":
                    jinjianInfo.setIsFk("1");
                    break;
                case "jjz":
                    jinjianInfo.setStatus("1");
                    break;
                case "dfk":
                    jinjianInfo.setJinjianStatus("1");
                    break;
            }
            customerService.updateStatusByJinJianStatus(jinjianInfo);
        }

    }


    /**
     * 业务设置 定时任务-取消锁定客户 每天凌晨1点
     *
     * @param
     */
    public void taskBusinessSettingByCancelLockCustomer() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            // 取消锁定
            businessSetBo = new BusinessSetBo();
            businessSetBo.setTime(businessSet.getManagerLockTimes());
            customerService.updateStatusCancelLock(businessSetBo);
        }

    }

    /**
     * 业务设置 定时任务-我的客户转公海 每天凌晨1点
     *
     * @param
     */
    public void taskBusinessSettingByMyCustomerToGonghai() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            // 我的客户去公海
            if ("1".equals(businessSet.getIsCustomerToGonghai())) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getCustomerToGonghaiTimes());
                customerService.updateStatusToHongHai48(businessSetBo);
            }
            if ("1".equals(businessSet.getIsOneStatus())) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getContactTimesToGonghaiOne());
                customerService.updateStatusToHongHai3(businessSetBo);
            }
            if ("1".equals(businessSet.getIsTwoStatus())) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getContactTimesToGonghaiTwo());
                customerService.updateStatusToHongHai15(businessSetBo);
            }
        }
    }

    /**
     * 业务设置 定时任务-线索池入公海 每天凌晨1点
     *
     * @param
     */
    public void taskBusinessSettingByXianSuoChiCustomerToGonghai() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            // 线索池去公海
            if ("1".equals(businessSet.getIsGetXianSuoToGonghai())) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getXianSuoToGonghaiTimes());
                customerService.updateStatusToHongHaiXianSuoChi(businessSetBo);
            }
        }
    }

    /**
     * 业务设置 定时任务-取消重复标记
     *
     * @param
     */
    public void taskBusinessSettingByCancelRepCustomer() {
        // 读取配置参数
        BusinessSet businessSet = businessSetService.get("index_set");
        if (null != businessSet) {
            BusinessSetBo businessSetBo = null;
            // 取消重复标记
            if ("1".equals(businessSet.getIsRepMarkTimes())) {
                businessSetBo = new BusinessSetBo();
                businessSetBo.setTime(businessSet.getRepMarkTimes());
                customerService.updateStatusCancelRep(businessSetBo);
            }
        }
    }

    /**
     * 10分钟未跟进 重新分配
     *
     * @param
     */
    public void taskCustomerNotGenJinRep(Integer times,String setTimeStr,String endTimeStr) throws ParseException {

        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        // 9.00-23.00
        Date setTime = sdf.parse(setTimeStr+":00:00");
        Date endTime = sdf.parse(endTimeStr+":00:00");
        LocalTime now = LocalTime.now();
        // 定义时间段
        LocalTime startTime1 = LocalTime.of(setTime.getHours(), setTime.getMinutes(),setTime.getSeconds()); // 上午9点
        LocalTime endTime1 = LocalTime.of(endTime.getHours(), endTime.getMinutes(),endTime.getSeconds()); // 晚上23点
        if (now.isAfter(startTime1) && now.isBefore(endTime1)) {
            BusinessSetBo businessSet = new BusinessSetBo();
            businessSet.setTime(times);
            Customer customer= customerService.findNotGen(businessSet);
            if (null != customer) {
                if (customerService.updateNotGen(customer)>0){
                    CustomerDongtai customerDongtai=new CustomerDongtai();
                    customerDongtai.setCustomerId(customer.getId());
                    customerDongtai.setType("1");
                    customerDongtai.setContent("【"+times+"】分钟内未跟进，重新分配");
                    customerDongtaiService.save(customerDongtai);
                    JSONObject jsonObject=new JSONObject();
                    jsonObject.put("type","xiezuCus");
                    jsonObject.put("msg","客户【"+customer.getCusName()+"】因规定时间没跟进，将重新分配");
                    WebSocketUsers.sendMessageToUserByText(WebSocketUsers.TYPE_PC,
                            customer.getUserId(), jsonObject.toJSONString());
                    // 扣除分配次数
                    SysUser user=iSysUserService.get(customer.getUserId());
                    user.setDayShareCount(user.getDayShareCount() - 1);
                    iSysUserService.updateDayShareCount(user);
                    // 删除临时分配表
//                    TempShare tempShare = new TempShare();
//                    tempShare.setSysUserId(user.getId());
//                    tempShare.setCustomerId(customer.getId());
//                    tempShareService.deleteRepFenPei(tempShare);
                }

            }
        }
        // 读取配置参数

    }

    /**
     * 融享客-新接口
     */
    public void taskGetRxkOrderCustomersNews() {
        RxkOrder rxkOrderparam = new RxkOrder();
        rxkOrderparam.setStatus("0");
        RxkOrder rxkOrder = rxkOrderService.findListByStatus(rxkOrderparam);
        if (StringUtils.isNotNull(rxkOrder)){
            int count =customerService.insertRongXinKe(rxkOrder.getOrderNo());
            if (count==1){
                rxkOrder.setStatus("1");
                rxkOrder.setVersion(rxkOrder.getVersion());
                rxkOrderService.save(rxkOrder);
            }

        }

    }


    public static void main(String[] args) throws ParseException {
//        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
//        // 9.00-23.00
//        Date setTime = sdf.parse("09:00:00");
//        Date endTime = sdf.parse("21:00:00");
//        LocalTime now = LocalTime.now();
//        // 定义时间段
//        LocalTime startTime1 = LocalTime.of(setTime.getHours(), setTime.getMinutes(),setTime.getSeconds()); // 上午9点
//        LocalTime endTime1 = LocalTime.of(endTime.getHours(), endTime.getMinutes(),endTime.getSeconds()); // 下午5点
//        System.out.println(now.isAfter(startTime1) && now.isBefore(endTime1));

//        taskGetRong360FuZhou();

        String[] area ="宁波".split("-");
        System.out.println(area[0]);

    }
}
